﻿using Basic.FlowLocalEvent.Model;
using WeDonekRpc.CacheClient.Interface;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;

namespace Basic.FlowApplication.LocalEvent
{
    [LocalEventName("Enable", "Stop")]
    internal class ClearFlowCache : IEventHandler<FlowEvent>
    {
        private readonly ILocalCacheController _LocalCache;

        public ClearFlowCache ( ILocalCacheController localCache )
        {
            this._LocalCache = localCache;
        }

        public void HandleEvent ( FlowEvent data, string eventName )
        {
            string key = "FlowBody_" + data.Flow.Id;
            _ = this._LocalCache.Remove(key);
        }
    }
}
